package com.uzai.console.web.md;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.common.utils.Tools;
import com.uzai.console.dto.md.mdactivity.MdActivityCopyDto;
import com.uzai.console.dto.md.mdactivity.MdActivityDto;
import com.uzai.console.dto.md.mdactivity.MdActivityIdDto;
import com.uzai.console.dto.md.mdactivity.MdActivityQuery;
import com.uzai.console.dto.md.mdgoods.MdGoodsTurnlinkDto;
import com.uzai.console.dto.pyq.pyqmaterial.TurnlinkDto;
import com.uzai.console.service.md.mdactivity.MdActivityService;
import com.uzai.console.vo.feign.turnlink.SimpleTurnlinkVo;
import com.uzai.console.vo.md.mdactivity.MdActivityCopyUrlVo;
import com.uzai.console.vo.md.mdactivity.MdActivityVo;
import com.uzai.console.vo.md.mdgoods.MdGoodsTurnlinkVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "免单活动",tags = "免单管理|免单活动")
@ApiSort(60)
@RestController
public class MdActivityContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MdActivityContoller.class);

    @Autowired
    private MdActivityService mdActivityService;

    @ApiOperation(value = "查询所有免单活动列表", notes = "查询所有免单活动列表", response = MdActivityVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/mdActivity/findMdActivityList")
    public Object findMdActivityList(@RequestBody MdActivityQuery mdActivityQuery){
        //默认私有活动
        mdActivityQuery.setSource(Tools.getInteger(mdActivityQuery.getSource()));
        return mdActivityService.findMdActivityList(mdActivityQuery);
    }

    @ApiOperation(value = "查询所有免单活动详情", notes = "查询所有免单活动详情", response = MdActivityVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/mdActivity/findMdActivity")
    public Object findMdActivity(@RequestBody MdActivityIdDto mdActivityIdDto){
        return mdActivityService.findMdActivity(mdActivityIdDto);
    }

    @ApiOperation(value = "添加免单活动", notes = "添加免单活动", response = Boolean.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/mdActivity/addMdActivity")
    public Object addMdActivity(@RequestBody MdActivityDto mdActivityDto){
        mdActivityService.addMdActivity(mdActivityDto);
        return true;
    }

    @ApiOperation(value = "修改免单活动", notes = "添加免单活动", response = Boolean.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/mdActivity/updateMdActivity")
    public Object updateMdActivity(@RequestBody MdActivityDto mdActivityDto){
        mdActivityService.updateMdActivity(mdActivityDto);
        return true;
    }

    @ApiOperation(value = "删除免单活动", notes = "删除免单活动", response = Boolean.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/mdActivity/deleteMdActivity")
    public Object deleteMdActivity(@RequestBody MdActivityIdDto mdActivityIdDto){
        mdActivityService.deleteMdActivity(mdActivityIdDto);
        return true;
    }

    @ApiOperation(value = "暂停免单活动", notes = "暂停免单活动", response = Boolean.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/mdActivity/pauseMdActivity")
    public Object pauseMdActivity(@RequestBody MdActivityIdDto mdActivityIdDto){
        mdActivityService.pauseMdActivity(mdActivityIdDto);
        return true;
    }

    @ApiOperation(value = "开启免单活动", notes = "开启免单活动", response = Boolean.class)
    @ApiOperationSupport(order = 7)
    @PostMapping("/mdActivity/startMdActivity")
    public Object startMdActivity(@RequestBody MdActivityIdDto mdActivityIdDto){
        mdActivityService.startMdActivity(mdActivityIdDto);
        return true;
    }

    @ApiOperation(value = "复制免单活动", notes = "复制免单活动", response = Boolean.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/mdActivity/copyMdActivity")
    public Object copyMdActivity(@RequestBody MdActivityCopyDto mdActivityCopyDto){
        mdActivityService.copyMdActivity(mdActivityCopyDto);
        return true;
    }

    @ApiOperation(value = "复制链接", notes = "复制链接", response = MdActivityCopyUrlVo.class)
    @ApiOperationSupport(order = 9)
    @PostMapping("/mdActivity/copyUrl")
    public Object copyUrl(@RequestBody MdActivityIdDto mdActivityIdDto){
        return mdActivityService.copyUrl(mdActivityIdDto);
    }

    @ApiOperation(value = "获取商品转链信息", notes = "获取商品转链信息", response = MdGoodsTurnlinkVo.class)
    @ApiOperationSupport(order = 10)
    @PostMapping("/mdActivity/getGoodsTurnlinkInfo")
    public Object getGoodsTurnlinkInfo(@RequestBody MdGoodsTurnlinkDto mdGoodsTurnlinkDto){
        return mdActivityService.getGoodsTurnlinkInfo(mdGoodsTurnlinkDto);
    }

}
